<?php
namespace app\usercp\controller;

use app\usercp\exception\UsercpException;
use think\Request;

class Admiration extends Usercp
{
    public function initialize() {
        parent::initialize();
        $this->service = model('article/Admiration', 'service');
    }

    /**
     * 点赞列表
     */
    public function index(Request $request)
    {
        $maps = [];
        $maps['current_id'] = 'mstsc6';
        $maps['site_id'] = '001001154288327238';
        $maps['status'] = $request->get('status');
        $maps['username'] = $request->get('username');
        $order = 'update_time desc';
        $list = $this->service->lists($maps,$order);
        var_dump($list);die;
    }

    /**
     * 删除点赞记录
     */
    public function delete($id)
    {
        if ($id < 1) {
            throw new UsercpException('点赞信息不能为空');
        }
        $current_id = 'mstsc6';
        $result = $this->service->destroy($id, $current_id);
        if (!$result) {
            throw new UsercpException($this->service->getError());
        }
        var_dump($result);die;
        return json(['code' => 0, 'message' => 'success']);

    }

}